package com.bj58.mis.apm.client.springboot.config;

import com.bj58.mis.apm.client.springboot.filter.ApmClientFilter;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.Ordered;
import org.springframework.core.annotation.Order;

/**
 * @author: zhangfx
 * @create: 2018-06-08 15:25
 **/
@Configuration
public class FilterConfig {
    @Bean
    public ApmClientFilter apmClientFilter(){
        return new ApmClientFilter();
    }

    @Bean
    public FilterRegistrationBean apmClientFilterRegistration() {
        FilterRegistrationBean registration = new FilterRegistrationBean();
        registration.setFilter(apmClientFilter());//添加过滤器
        registration.addUrlPatterns("/*");//设置过滤路径，/*所有路径
        registration.setName("ApmClientFilter");
        registration.setOrder(Ordered.HIGHEST_PRECEDENCE);//设置优先级
        return registration;
    }

}
